package com.linkhub.oms.data.sync.api.wms.domain.request;

import com.alibaba.fastjson.annotation.JSONField;
import com.linkhub.oms.common.util.QtBeanUtil;
import com.linkhub.oms.data.sync.api.wms.domain.dto.WmsStockOutBatchCreateDTO;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @author Jaycle
 * @version 1.0.0
 * @Description StockOutBatchCreateRequest.java
 * @createTime 2024/06/20 13:39
 */
@NoArgsConstructor
@Data
public class StockOutBatchCreateRequest implements Serializable {

    /**
     * request
     */
    @JSONField(name = "request")
    private Request request;

    public static StockOutBatchCreateRequest createRequest( WmsStockOutBatchCreateDTO wmsCreateDeliveryListDTO ) {
        StockOutBatchCreateRequest request = new StockOutBatchCreateRequest();
        Request req = new Request();
        req.setOutBizCode(wmsCreateDeliveryListDTO.getOutBizCode());

        Request.Orders orders = new Request.Orders();
        ArrayList<Request.Orders.Order> orderArrayList = new ArrayList<>();
        orders.setOrder(orderArrayList);

        List<WmsStockOutBatchCreateDTO.Order> dtoOrders = wmsCreateDeliveryListDTO.getOrders();
        if (dtoOrders != null) {
            for (WmsStockOutBatchCreateDTO.Order dtoOrder : dtoOrders) {
                Request.Orders.Order order = new Request.Orders.Order();
//                Request.Orders.Order.DeliveryOrder deliveryOrder = new Request.Orders.Order.DeliveryOrder();
//                QtBeanUtil.copyProperties(dtoOrder.getDeliveryOrder(), deliveryOrder);
//
//                Request.Orders.Order.OrderLines orderLines = new Request.Orders.Order.OrderLines();
//                QtBeanUtil.copyProperties(dtoOrder.getOrderLines(), orderLines);
//
//                order.setDeliveryOrder(deliveryOrder);
//                order.setOrderLines(orderLines);
                QtBeanUtil.copyProperties(dtoOrder, order);
                orders.getOrder().add(order);
            }
        }

        req.setOrders(orders);
        request.setRequest(req);
        return request;
    }

    @NoArgsConstructor
    @Data
    public static class Request {
        /**
         * outBizCode
         */
        @JSONField(name = "outBizCode")
        private String outBizCode;

        /**
         * orders
         */
        @JSONField(name = "orders")
        private Orders orders;

        @NoArgsConstructor
        @Data
        public static class Orders {
            /**
             * order
             */
            @JSONField(name = "order")
            private List<Order> order;

            @NoArgsConstructor
            @Data
            public static class Order {
                /**
                 * deliveryOrder
                 */
                @JSONField(name = "deliveryOrder")
                private DeliveryOrder deliveryOrder;

                /**
                 * orderLines
                 */
                @JSONField(name = "orderLines")
                private OrderLines orderLines;

                @NoArgsConstructor
                @Data
                public static class DeliveryOrder {
                    /**
                     * deliveryOrderCode
                     */
                    @JSONField(name = "deliveryOrderCode")
                    private String deliveryOrderCode;

                    /**
                     * orderType
                     */
                    @JSONField(name = "orderType")
                    private String orderType;

                    /**
                     * warehouseCode
                     */
                    @JSONField(name = "warehouseCode")
                    private String warehouseCode;

                    /**
                     * ownerCode
                     */
                    @JSONField(name = "ownerCode")
                    private String ownerCode;

                    /**
                     * createTime
                     */
                    @JSONField(name = "createTime")
                    private String createTime;

                    /**
                     * placedAt
                     */
                    @JSONField(name = "placedAt")
                    private String placedAt;

                    /**
                     * payTime
                     */
                    @JSONField(name = "payTime")
                    private String payTime;

                    /**
                     * datePlanned
                     */
                    @JSONField(name = "datePlanned")
                    private String datePlanned;

                    /**
                     * sourcePlatformCode
                     */
                    @JSONField(name = "sourcePlatformCode")
                    private String sourcePlatformCode;

                    /**
                     * logisticsCode
                     */
                    @JSONField(name = "logisticsCode")
                    private String logisticsCode;

                    /**
                     * expressCode
                     */
                    @JSONField(name = "expressCode")
                    private String expressCode;

                    /**
                     * printData
                     */
                    @JSONField(name = "printData")
                    private String printData;

                    /**
                     * shopNick
                     */
                    @JSONField(name = "shopNick")
                    private String shopNick;

                    /**
                     * entryOrderCode
                     */
                    @JSONField(name = "entryOrderCode")
                    private String entryOrderCode;

                    /**
                     * carrryRoute
                     */
                    @JSONField(name = "carrryRoute")
                    private String carrryRoute;

                    /**
                     * customerCode
                     */
                    @JSONField(name = "customerCode")
                    private String customerCode;

                    /**
                     * customer
                     */
                    @JSONField(name = "customer")
                    private String customer;

                    /**
                     * documentMaker
                     */
                    @JSONField(name = "documentMaker")
                    private String documentMaker;

                    /**
                     * invoiceFlag
                     */
                    @JSONField(name = "invoiceFlag")
                    private String invoiceFlag;

                    /**
                     * buyerMessage
                     */
                    @JSONField(name = "buyerMessage")
                    private String buyerMessage;

                    /**
                     * sellerMessage
                     */
                    @JSONField(name = "sellerMessage")
                    private String sellerMessage;

                    /**
                     * invoices
                     */
                    @JSONField(name = "invoices")
                    private Invoices invoices;

                    @NoArgsConstructor
                    @Data
                    public static class Invoices {
                        /**
                         * invoice
                         */
                        @JSONField(name = "invoice")
                        private List<Invoice> invoice;

                        @NoArgsConstructor
                        @Data
                        public static class Invoice {
                            /**
                             * type
                             */
                            @JSONField(name = "type")
                            private String type;

                            /**
                             * header
                             */
                            @JSONField(name = "header")
                            private String header;

                            /**
                             * amount
                             */
                            @JSONField(name = "amount")
                            private String amount;

                            /**
                             * content
                             */
                            @JSONField(name = "content")
                            private String content;

                            /**
                             * taxNumber
                             */
                            @JSONField(name = "taxNumber")
                            private String taxNumber;

                            /**
                             * detail
                             */
                            @JSONField(name = "detail")
                            private Detail detail;

                            @NoArgsConstructor
                            @Data
                            public static class Detail {
                                /**
                                 * items
                                 */
                                @JSONField(name = "items")
                                private Items items;

                                @NoArgsConstructor
                                @Data
                                public static class Items {
                                    /**
                                     * item
                                     */
                                    @JSONField(name = "item")
                                    private List<Item> item;

                                    @NoArgsConstructor
                                    @Data
                                    public static class Item {
                                        /**
                                         * itemName
                                         */
                                        @JSONField(name = "itemName")
                                        private String itemName;

                                        /**
                                         * unit
                                         */
                                        @JSONField(name = "unit")
                                        private String unit;

                                        /**
                                         * price
                                         */
                                        @JSONField(name = "price")
                                        private String price;

                                        /**
                                         * quantity
                                         */
                                        @JSONField(name = "quantity")
                                        private String quantity;

                                        /**
                                         * amount
                                         */
                                        @JSONField(name = "amount")
                                        private String amount;
                                    }
                                }
                            }
                        }
                    }

                    /**
                     * senderInfo
                     */
                    @JSONField(name = "senderInfo")
                    private SenderInfo senderInfo;

                    @NoArgsConstructor
                    @Data
                    public static class SenderInfo {
                        /**
                         * company
                         */
                        @JSONField(name = "company")
                        private String company;

                        /**
                         * name
                         */
                        @JSONField(name = "name")
                        private String name;

                        /**
                         * zipCode
                         */
                        @JSONField(name = "zipCode")
                        private String zipCode;

                        /**
                         * mobile
                         */
                        @JSONField(name = "mobile")
                        private String mobile;

                        /**
                         * countryCode
                         */
                        @JSONField(name = "countryCode")
                        private String countryCode;

                        /**
                         * province
                         */
                        @JSONField(name = "province")
                        private String province;

                        /**
                         * city
                         */
                        @JSONField(name = "city")
                        private String city;

                        /**
                         * area
                         */
                        @JSONField(name = "area")
                        private String area;

                        /**
                         * town
                         */
                        @JSONField(name = "town")
                        private String town;

                        /**
                         * detailAddress
                         */
                        @JSONField(name = "detailAddress")
                        private String detailAddress;
                    }

                    /**
                     * receiverInfo
                     */
                    @JSONField(name = "receiverInfo")
                    private ReceiverInfo receiverInfo;

                    @NoArgsConstructor
                    @Data
                    public static class ReceiverInfo {
                        /**
                         * company
                         */
                        @JSONField(name = "company")
                        private String company;

                        /**
                         * name
                         */
                        @JSONField(name = "name")
                        private String name;

                        /**
                         * zipCode
                         */
                        @JSONField(name = "zipCode")
                        private String zipCode;

                        /**
                         * tel
                         */
                        @JSONField(name = "tel")
                        private String tel;

                        /**
                         * mobile
                         */
                        @JSONField(name = "mobile")
                        private String mobile;

                        /**
                         * countryCode
                         */
                        @JSONField(name = "countryCode")
                        private String countryCode;

                        /**
                         * province
                         */
                        @JSONField(name = "province")
                        private String province;

                        /**
                         * city
                         */
                        @JSONField(name = "city")
                        private String city;

                        /**
                         * area
                         */
                        @JSONField(name = "area")
                        private String area;

                        /**
                         * town
                         */
                        @JSONField(name = "town")
                        private String town;

                        /**
                         * detailAddress
                         */
                        @JSONField(name = "detailAddress")
                        private String detailAddress;

                        /**
                         * oaid
                         */
                        @JSONField(name = "oaid")
                        private String oaid;
                    }

                    /**
                     * customJson
                     */
                    @JSONField(name = "customJson")
                    private String customJson;

                    /**
                     * remark
                     */
                    @JSONField(name = "remark")
                    private String remark;

                    /**
                     * userDefined1
                     */
                    @JSONField(name = "userDefined1")
                    private String userDefined1;

                    /**
                     * userDefined2
                     */
                    @JSONField(name = "userDefined2")
                    private String userDefined2;

                    /**
                     * userDefined3
                     */
                    @JSONField(name = "userDefined3")
                    private String userDefined3;

                    /**
                     * userDefined4
                     */
                    @JSONField(name = "userDefined4")
                    private String userDefined4;

                    /**
                     * sourceOrderCode
                     */
                    @JSONField(name = "sourceOrderCode")
                    private String sourceOrderCode;

                    /**
                     * files
                     */
                    @JSONField(name = "files")
                    private Files files;

                    @NoArgsConstructor
                    @Data
                    public static class Files {
                        /**
                         * file
                         */
                        @JSONField(name = "file")
                        private List<File> file;

                        @NoArgsConstructor
                        @Data
                        public static class File {
                            /**
                             * name
                             */
                            @JSONField(name = "name")
                            private String name;

                            /**
                             * url
                             */
                            @JSONField(name = "url")
                            private String url;
                        }
                    }

                }

                @NoArgsConstructor
                @Data
                public static class OrderLines {
                    /**
                     * orderLine
                     */
                    @JSONField(name = "orderLine")
                    private List<OrderLine> orderLine;

                    @NoArgsConstructor
                    @Data
                    public static class OrderLine {
                        /**
                         * lineNo
                         */
                        @JSONField(name = "lineNo")
                        private String lineNo;

                        /**
                         * itemCode
                         */
                        @JSONField(name = "itemCode")
                        private String itemCode;

                        /**
                         * itemId
                         */
                        @JSONField(name = "itemId")
                        private String itemId;

                        /**
                         * planQty
                         */
                        @JSONField(name = "planQty")
                        private String planQty;

                        /**
                         * actualPrice
                         */
                        @JSONField(name = "actualPrice")
                        private String actualPrice;

                        /**
                         * inventoryType
                         */
                        @JSONField(name = "inventoryType")
                        private String inventoryType;

                        /**
                         * virtualWarehouse
                         */
                        @JSONField(name = "virtualWarehouse")
                        private String virtualWarehouse;

                        /**
                         * productDate
                         */
                        @JSONField(name = "productDate")
                        private String productDate;

                        /**
                         * expireDate
                         */
                        @JSONField(name = "expireDate")
                        private String expireDate;

                        /**
                         * batchCode
                         */
                        @JSONField(name = "batchCode")
                        private String batchCode;

                        /**
                         * stockinDate
                         */
                        @JSONField(name = "stockinDate")
                        private String stockinDate;

                        /**
                         * userDefined1
                         */
                        @JSONField(name = "userDefined1")
                        private String userDefined1;

                        /**
                         * userDefined2
                         */
                        @JSONField(name = "userDefined2")
                        private String userDefined2;

                        /**
                         * userDefined3
                         */
                        @JSONField(name = "userDefined3")
                        private String userDefined3;

                        /**
                         * userDefined4
                         */
                        @JSONField(name = "userDefined4")
                        private String userDefined4;

                        /**
                         * customJson
                         */
                        @JSONField(name = "customJson")
                        private CustomJson customJson;

                        @NoArgsConstructor
                        @Data
                        public static class CustomJson {
                        }

                        /**
                         * customField1
                         */
                        @JSONField(name = "customField1")
                        private String customField1;

                        /**
                         * customField2
                         */
                        @JSONField(name = "customField2")
                        private String customField2;

                        /**
                         * customField3
                         */
                        @JSONField(name = "customField3")
                        private String customField3;

                        /**
                         * customField4
                         */
                        @JSONField(name = "customField4")
                        private String customField4;

                        /**
                         * customField5
                         */
                        @JSONField(name = "customField5")
                        private String customField5;

                        /**
                         * customField6
                         */
                        @JSONField(name = "customField6")
                        private String customField6;

                        /**
                         * customField7
                         */
                        @JSONField(name = "customField7")
                        private String customField7;

                        /**
                         * customField8
                         */
                        @JSONField(name = "customField8")
                        private String customField8;
                    }
                }
            }
        }
    }
}
